<template>
  <el-dialog :visible.sync="visible" :title="!dataForm.id ? '新增' : '修改'" :close-on-click-modal="false">
    <el-form ref="dataFormRef" :model="dataForm" :rules="dataRules" label-width="100px" @keyup.enter="submitHandle()">
      <el-row>
        <el-col :span="24">
          <el-form-item label="ID" prop="id">
            <el-input v-model="dataForm.id" placeholder="ID" />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="业务主键" prop="businessKey">
            <el-input v-model="dataForm.businessKey" placeholder="业务主键" />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="附件ID" prop="attachId">
            <el-input v-model="dataForm.attachId" placeholder="附件ID" />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="领域" prop="domain">
            <el-input v-model="dataForm.domain" placeholder="领域" />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="大修轮次" prop="overhaulRotation">
            <el-input v-model="dataForm.overhaulRotation" placeholder="大修轮次" />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="检查日期" prop="checkDate">
            <el-input v-model="dataForm.checkDate" placeholder="检查日期" />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="专项检查名称" prop="specialInspectionName">
            <el-input v-model="dataForm.specialInspectionName" placeholder="专项检查名称" />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="类别" prop="category">
            <el-input v-model="dataForm.category" placeholder="类别" />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="分级" prop="grading">
            <el-input v-model="dataForm.grading" placeholder="分级" />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="发现问题" prop="findProblem">
            <el-input v-model="dataForm.findProblem" placeholder="发现问题" />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="法律法规" prop="law">
            <el-input v-model="dataForm.law" placeholder="法律法规" />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="现场照片" prop="scenePhoto">
            <el-input v-model="dataForm.scenePhoto" placeholder="现场照片" />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="整改要求" prop="rectification">
            <el-input v-model="dataForm.rectification" placeholder="整改要求" />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="责任单位" prop="responsibleUnit">
            <el-input v-model="dataForm.responsibleUnit" placeholder="责任单位" />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="责任单位责任人员工号" prop="responsibleUnitUserCode">
            <el-input v-model="dataForm.responsibleUnitUserCode" placeholder="责任单位责任人员工号" />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="责任单位责任人员姓名" prop="responsibleUnitUserName">
            <el-input v-model="dataForm.responsibleUnitUserName" placeholder="责任单位责任人员姓名" />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="管理部门" prop="manage">
            <el-input v-model="dataForm.manage" placeholder="管理部门" />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="管理单位责任人员工号" prop="manageUnitUserCode">
            <el-input v-model="dataForm.manageUnitUserCode" placeholder="管理单位责任人员工号" />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="管理单位责任人员姓名" prop="manageUnitUserName">
            <el-input v-model="dataForm.manageUnitUserName" placeholder="管理单位责任人员姓名" />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="整改期限" prop="rectificationLimitTime">
            <el-input v-model="dataForm.rectificationLimitTime" placeholder="整改期限" />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="提醒天数" prop="remindNumber">
            <el-input v-model="dataForm.remindNumber" placeholder="提醒天数" />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="是否已有任务督办" prop="taskSupervisorStatus">
            <el-input v-model="dataForm.taskSupervisorStatus" placeholder="是否已有任务督办" />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="任务督办号" prop="taskSupervisorCode">
            <el-input v-model="dataForm.taskSupervisorCode" placeholder="任务督办号" />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="是否立行立改" prop="legislativeReformStatus">
            <el-input v-model="dataForm.legislativeReformStatus" placeholder="是否立行立改" />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="备注" prop="remark">
            <el-input v-model="dataForm.remark" placeholder="备注" />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="创建人工号" prop="createdUserCode">
            <el-input v-model="dataForm.createdUserCode" placeholder="创建人工号" />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="创建人姓名" prop="createdUserName">
            <el-input v-model="dataForm.createdUserName" placeholder="创建人姓名" />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="创建时间" prop="createdTime">
            <el-input v-model="dataForm.createdTime" placeholder="创建时间" />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="修改人工号" prop="updatedUserCode">
            <el-input v-model="dataForm.updatedUserCode" placeholder="修改人工号" />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="修改人姓名" prop="updatedUserName">
            <el-input v-model="dataForm.updatedUserName" placeholder="修改人姓名" />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="修改时间" prop="updatedTime">
            <el-input v-model="dataForm.updatedTime" placeholder="修改时间" />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="删除标志" prop="delFlag">
            <el-input v-model="dataForm.delFlag" placeholder="删除标志" />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <template #footer>
      <el-button @click="visible = false">取消</el-button>
      <el-button type="primary" @click="submitHandle()">确定</el-button>
    </template>
  </el-dialog>
</template>

<script>
import { useEnvironmental_hidden_dangerApi, useEnvironmental_hidden_dangerSubmitApi } from '@/api/business/environmental_hidden_danger'

export default {
  name: 'AddOrUpdate',
  data() {
    return {
      visible: false,
      dataForm: {
        id: '',
        businessKey: '',
        attachId: '',
        domain: '',
        overhaulRotation: '',
        checkDate: '',
        specialInspectionName: '',
        category: '',
        grading: '',
        findProblem: '',
        law: '',
        scenePhoto: '',
        rectification: '',
        responsibleUnit: '',
        responsibleUnitUserCode: '',
        responsibleUnitUserName: '',
        manage: '',
        manageUnitUserCode: '',
        manageUnitUserName: '',
        rectificationLimitTime: '',
        remindNumber: '',
        taskSupervisorStatus: '',
        taskSupervisorCode: '',
        legislativeReformStatus: '',
        remark: '',
        createdUserCode: '',
        createdUserName: '',
        createdTime: '',
        updatedUserCode: '',
        updatedUserName: '',
        updatedTime: '',
        delFlag: '' },
      dataRules: {
      }
    }
  },
  methods: {
    init(id) {
      this.visible = true
      this.dataForm.id = ''
      const formInstance = this.$refs.dataFormRef
      if (formInstance) {
        formInstance.resetFields()
      }
      if (id) {
        this.getEnvironmental_hidden_danger(id)
      }
    },
    getEnvironmental_hidden_danger(id) {
      useEnvironmental_hidden_dangerApi(id).then(res => {
        Object.assign(this.dataForm, res.data)
      })
    },
    submitHandle() {
      this.$refs.dataFormRef.validate((valid) => {
        if (!valid) {
          return false
        }
        useEnvironmental_hidden_dangerSubmitApi(this.dataForm).then(() => {
          this.$message.success({
            message: '操作成功',
            duration: 500,
            onClose: () => {
              this.visible = false
              this.$emit('refreshDataList')
            }
          })
        })
      })
    }
  }
}
</script>
